package day02;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

public class ConPoolDemo {
    public static void main(String[] args) {
        //硬编码方式使用
        ComboPooledDataSource cpds = new ComboPooledDataSource();
        try {
            cpds.setDriverClass("com.mysql.cj.jdbc.Driver");
            cpds.setJdbcUrl("jdbc:mysql://localhost:3306/dalwin_learn?serverTimezone=UTC");
            cpds.setUser("root");
            cpds.setPassword("123456");
            System.out.println(cpds);
            Connection con = cpds.getConnection();
            System.out.println(con);
            con.close();
            cpds.close();
        } catch (PropertyVetoException | SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
